/**
 * @description router全局配置，如有必要可分文件抽离，其中asyncRoutes只有在intelligence模式下才会用到，vip文档中已提供路由的基础图标与小清新图标的配置方案，请仔细阅读
 */

import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/layouts'
import EmptyLayout from '@/layouts/EmptyLayout'
import { publicPath, routerMode } from '@/config'

Vue.use(VueRouter)
export const constantRoutes = [
  // {
  //   path: '/alarmStatistics',
  //   component: () => import('@/views/alarmStatistics/index'),
  //   hidden: true,
  // },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true,
  },
  {
    path: '/register',
    component: () => import('@/views/register/index'),
    hidden: true,
  },
  {
    path: '/401',
    name: '401',
    component: () => import('@/views/401'),
    hidden: true,
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/404'),
    hidden: true,
  },
]

export const asyncRoutes = [
  {
    path: '/',
    component: Layout,
    redirect: '/index',
    hidden: true,
    children: [
      {
        path: 'index',
        name: 'Index',
        component: () => import('@/views/index/index'),
        meta: {
          title: '工作台',
          icon: 'home',
          affix: true,
        },
      },
    ],
  },
  /* {
    path: "/test",
    component: Layout,
    redirect: "noRedirect",
    children: [
      {
        path: "test",
        name: "Test",
        component: () => import("@/views/test/index"),
        meta: {
          title: "test",
          icon: "marker",
          permissions: ["admin"],
        },
      },
    ],
  }, */
  {
    path: '/project',
    component: Layout,
    redirect: 'noRedirect',
    name: 'Project',
    alwaysShow: true,
    hidden: true,
    meta: { title: '项目管理', icon: 'file-alt' },
    children: [
      {
        path: 'index',
        name: 'Index',
        component: () => import('@/views/project/index/index'),
        meta: {
          title: '项目管理',
          permissions: ['admin', 'editor'],
        },
      },
      {
        path: 'item',
        name: 'Item',
        hidden: true,
        component: () => import('@/views/project/item/index'),
        meta: {
          title: '项目信息',
          permissions: ['admin', 'editor'],
        },
      },
      {
        path: 'device',
        name: 'Device',
        hidden: true,
        component: () => import('@/views/project/device/index'),
        meta: {
          title: '设备管理',
          permissions: ['admin', 'editor'],
        },
      },
    ],
  },
  {
    path: '/alarmStatistics',
    component: Layout,
    redirect: 'noRedirect',
    name: 'AlarmStatistics',
    alwaysShow: true,
    hidden: true,
    meta: { title: '报警统计', icon: 'file-alt' },
    children: [
      {
        path: 'alarmIndex',
        name: 'AlarmIndex',
        component: () => import('@/views/alarmStatistics/index'),
        meta: {
          title: '报警统计',
          permissions: ['admin', 'editor'],
        },
      },
      {
        path: 'alarmList',
        name: 'AlarmList',
        component: () => import('@/views/alarmStatistics/list'),
        meta: {
          title: '项目报警列表',
          permissions: ['admin', 'editor'],
        },
      },
      {
        path: 'alarmReport',
        name: 'AlarmReport',
        component: () => import('@/views/alarmStatistics/report'),
        meta: {
          title: '项目报警总览',
          permissions: ['admin', 'editor'],
        },
      },
      {
        path: 'ioReport',
        name: 'IoReport',
        component: () => import('@/views/alarmStatistics/IoReport'),
        meta: {
          title: '设备报警总览',
          permissions: ['admin', 'editor'],
        },
      },
    ],
  },
  // {
  //   path: '/workList',
  //   component: Layout,
  //   redirect: 'noRedirect',
  //   name: 'WorkList',
  //   alwaysShow: true,
  //   meta: { title: '工单管理', icon: 'file-alt' },
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'Index',
  //       component: () => import('@/views/workList/index/index'),
  //       meta: {
  //         title: '工单管理',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //     {
  //       path: 'all',
  //       name: 'All',
  //       component: () => import('@/views/workList/all/index'),
  //       meta: {
  //         title: '工单合计',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //     {
  //       path: 'one',
  //       name: 'One',
  //       component: () => import('@/views/workList/one/index'),
  //       meta: {
  //         title: '一部',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //     {
  //       path: 'two',
  //       name: 'Two',
  //       component: () => import('@/views/workList/two/index'),
  //       meta: {
  //         title: '二部',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //     {
  //       path: 'three',
  //       name: 'Three',
  //       component: () => import('@/views/workList/three/index'),
  //       meta: {
  //         title: '三部',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //     {
  //       path: 'lowerMachine',
  //       name: 'LowerMachine',
  //       component: () => import('@/views/workList/lowerMachine/index'),
  //       meta: {
  //         title: '下位机',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //     {
  //       path: 'innovation',
  //       name: 'Innovation',
  //       component: () => import('@/views/workList/innovation/index'),
  //       meta: {
  //         title: '公共创新',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //     {
  //       path: 'reportforms',
  //       name: 'Reportforms',
  //       component: () => import('@/views/workList/reportforms/index'),
  //       meta: {
  //         title: '报表',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //   ],
  // },
  // {
  //   path: '/dicSetting',
  //   component: Layout,
  //   redirect: 'noRedirect',
  //   name: 'dicSetting',
  //   alwaysShow: true,
  //   meta: { title: '通用配置', icon: 'dharmachakra' },
  //   children: [
  //     {
  //       path: 'user',
  //       name: 'User',
  //       component: () => import('@/views/dicSetting/user/index'),
  //       meta: {
  //         title: '用户管理',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //     {
  //       path: 'project',
  //       name: 'Project',
  //       component: () => import('@/views/dicSetting/project/index'),
  //       meta: {
  //         title: '项目配置',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //     {
  //       path: 'department',
  //       name: 'Department',
  //       component: () => import('@/views/dicSetting/department/index'),
  //       meta: {
  //         title: '部门配置',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //     {
  //       path: 'rank',
  //       name: 'Rank',
  //       component: () => import('@/views/dicSetting/rank/index'),
  //       meta: {
  //         title: '职级管理',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //     {
  //       path: 'leaveInfo',
  //       name: 'LeaveInfo',
  //       component: () => import('@/views/dicSetting/leaveInfo/index'),
  //       meta: {
  //         title: '请假信息管理',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //     {
  //       path: 'awayInfo',
  //       name: 'AwayInfo',
  //       component: () => import('@/views/dicSetting/awayInfo/index'),
  //       meta: {
  //         title: '出差信息管理',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //     {
  //       path: 'workLevel',
  //       name: 'WorkLevel',
  //       component: () => import('@/views/dicSetting/workLevel/index'),
  //       meta: {
  //         title: '工单等级配置',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //   ],
  // },
  // {
  //   path: '/vab',
  //   component: Layout,
  //   redirect: 'noRedirect',
  //   name: 'Vab',
  //   alwaysShow: true,
  //   meta: { title: '组件', icon: 'box-open' },
  //   children: [
  //     {
  //       path: 'permissions',
  //       name: 'Permission',
  //       component: () => import('@/views/vab/permissions/index'),
  //       meta: {
  //         title: '角色权限',
  //         permissions: ['admin', 'editor'],
  //       },
  //     },
  //     {
  //       path: 'icon',
  //       component: EmptyLayout,
  //       redirect: 'noRedirect',
  //       name: 'Icon',
  //       meta: {
  //         title: '图标',
  //         permissions: ['admin'],
  //       },
  //       children: [
  //         {
  //           path: 'awesomeIcon',
  //           name: 'AwesomeIcon',
  //           component: () => import('@/views/vab/icon/index'),
  //           meta: { title: '常规图标' },
  //         },
  //         {
  //           path: 'colorfulIcon',
  //           name: 'ColorfulIcon',
  //           component: () => import('@/views/vab/icon/colorfulIcon'),
  //           meta: { title: '多彩图标' },
  //         },
  //       ],
  //     },
  //     {
  //       path: 'table',
  //       component: () => import('@/views/vab/table/index'),
  //       name: 'Table',
  //       meta: {
  //         title: '表格',
  //         permissions: ['admin'],
  //       },
  //     },

  //     {
  //       path: 'webSocket',
  //       name: 'WebSocket',
  //       component: () => import('@/views/vab/webSocket/index'),
  //       meta: { title: 'webSocket', permissions: ['admin'] },
  //     },
  //     {
  //       path: 'form',
  //       name: 'Form',
  //       component: () => import('@/views/vab/form/index'),
  //       meta: { title: '表单', permissions: ['admin'] },
  //     },
  //     {
  //       path: 'element',
  //       name: 'Element',
  //       component: () => import('@/views/vab/element/index'),
  //       meta: { title: '常用组件', permissions: ['admin'] },
  //     },
  //     {
  //       path: 'tree',
  //       name: 'Tree',
  //       component: () => import('@/views/vab/tree/index'),
  //       meta: { title: '树', permissions: ['admin'] },
  //     },
  //     {
  //       path: 'upload',
  //       name: 'Upload',
  //       component: () => import('@/views/vab/upload/index'),
  //       meta: { title: '上传', permissions: ['admin'] },
  //     },
  //   ],
  // },
  // {
  //   path: '/personnelManagement',
  //   component: Layout,
  //   redirect: 'noRedirect',
  //   name: 'PersonnelManagement',
  //   meta: { title: '配置', icon: 'users-cog', permissions: ['admin'] },
  //   children: [
  //     {
  //       path: 'userManagement',
  //       name: 'UserManagement',
  //       component: () => import('@/views/personnelManagement/userManagement/index'),
  //       meta: { title: '用户管理', icon: 'users-cog', permissions: ['admin'] },
  //     },
  //     {
  //       path: 'roleManagement',
  //       name: 'RoleManagement',
  //       component: () => import('@/views/personnelManagement/roleManagement/index'),
  //       meta: { title: '角色管理' },
  //     },
  //     {
  //       path: 'menuManagement',
  //       name: 'MenuManagement',
  //       component: () => import('@/views/personnelManagement/menuManagement/index'),
  //       meta: { title: '菜单管理', badge: 'New' },
  //     },
  //   ],
  // },
  // {
  //   path: '/error',
  //   component: EmptyLayout,
  //   redirect: 'noRedirect',
  //   name: 'Error',
  //   meta: { title: '错误页', icon: 'bug' },
  //   children: [
  //     {
  //       path: '401',
  //       name: 'Error401',
  //       component: () => import('@/views/401'),
  //       meta: { title: '401' },
  //     },
  //     {
  //       path: '404',
  //       name: 'Error404',
  //       component: () => import('@/views/404'),
  //       meta: { title: '404' },
  //     },
  //   ],
  // },
  {
    path: '*',
    redirect: '/404',
    hidden: true,
  },
]

const router = new VueRouter({
  base: publicPath,
  mode: routerMode,
  scrollBehavior: () => ({
    y: 0,
  }),
  routes: constantRoutes,
})

export function resetRouter() {
  location.reload()
}

export default router
